using AndroidCaller;
using System.Collections;
using UnityEngine;

public class SocialReward : MonoBehaviour
{
	public CoinsController CoinsController;

	public GarageController GarageController;

	public DialogController DialogController;

	public GameObject free_coins_icon;

	public GameObject yt_bonus;

	public GameObject fb_bonus;

	public GameObject tw_bonus;

	public GameObject insta_bonus;

	private void Start()
	{
		free_coins_icon.SetActive(value: false);
		ShowBonusLinks();
	}

	public void ShowBonusLinks()
	{
		int num = 0;
		if (PlayerPrefs.GetInt("facebook_bonus", 0) == 1)
		{
			fb_bonus.SetActive(value: false);
			num++;
		}
		if (PlayerPrefs.GetInt("youtube_bonus", 0) == 1)
		{
			yt_bonus.SetActive(value: false);
			num++;
		}
		if (PlayerPrefs.GetInt("twitter_bonus", 0) == 1)
		{
			tw_bonus.SetActive(value: false);
			num++;
		}
		if (PlayerPrefs.GetInt("instagram_bonus", 0) == 1)
		{
			insta_bonus.SetActive(value: false);
			num++;
		}
		if (num >= 4)
		{
			free_coins_icon.SetActive(value: false);
		}
	}

	public void ShowGetFreeCoins()
	{
		free_coins_icon.SetActive(value: true);
		ShowBonusLinks();
	}

	public void GetFreeCoinsClick()
	{
		DialogController.ShowRewardsDialog();
		ShowBonusLinks();
	}

	public void GetCoinsClick(string network)
	{
		StartCoroutine(AddReward(3f, network));
		//NativeCall.CallArg("opensocial", network);
	}

	private IEnumerator AddReward(float seconds, string network)
	{
		float pauseEndTime = Time.realtimeSinceStartup + seconds;
		while (Time.realtimeSinceStartup < pauseEndTime)
		{
			yield return 0;
		}
		CoinsController.AddCoins(250);
		GarageController.RefreshCoins();
		PlayerPrefs.SetInt(network + "_bonus", 1);
		DialogController.HideAllDialogs();
		DialogController.ShowRewardedDialog();
	}
}
